Crispo - Excel Challenge 11 2025

excel-challenges
weekly-exercises
Easy Sunday Excel Challenge
Published

March 16, 2025

Illustration for Crispo - Excel Challenge 11 2025

Challenge Description

Easy Sunday Excel Challenge

⭐ PROBLEM SOLUTION SUB-DEPARTMENT NAMES SALES & MARKETING PROCUREMENT ADMIN

Solutions

  • Logic:

    • Applies the workbook rule directly and shapes the expected output
  • Strengths:

    • The R solution stays compact and mirrors the workbook logic closely.
  • Areas for Improvement:

    • The code assumes the workbook layout and named ranges remain stable.
  • Gem:

    • The best part of the solution is choosing a tidy intermediate shape before producing the final answer.
import pandas as pd

path = "files/CHALLENGE 1205.xlsx"
input = pd.read_excel(path, usecols="B", skiprows=2, nrows=11)
test = pd.read_excel(path, usecols="D:G", skiprows=2, nrows=4)

input[['sub_department', 'department']] = input['SUB-DEPARTMENT NAMES'].str.split('-', n=1, expand=True)
input['rn'] = input.groupby('sub_department').cumcount() + 1
input = input.drop(columns=['department'])

result = input.pivot(index='rn', columns='sub_department', values='SUB-DEPARTMENT NAMES').reindex(columns=input['sub_department'].unique()).reset_index(drop=True)
result.index.name = None
result.columns.name = None

print(result.equals(test)) # True
  • Logic:

    • Reads the workbook range needed for the challenge

    • Reshapes the data to the grain required by the task

    • Aggregates or ranks values at the correct grouping level

  • Strengths:

    • The Python version keeps the same rule in a direct pandas-oriented workflow.
  • Areas for Improvement:

    • As with the R version, any workbook layout change would require small adjustments.
  • Gem:

    • The implementation stays close to the stated challenge instead of adding unnecessary complexity.

Difficulty Level

This task is easy to moderate:

  • The business rule is readable, but the workbook still needs a few careful transformation steps.